Skip to content

Conversation

@svastven
Copy link

@svastven svastven commented Jan 6, 2026

This PR fixes an issue where window insets (like statusBarsPadding()) did not correctly respect or propagate consumed window insets. The core problem was that the InsetsPaddingModifierNode logic was "hidden" from the layout traversal system because it was implemented via delegation.

The Modifier.windowInsetsPadding now applies two separate modifiers which create nodes of two types:

  • PlatformInsetsPaddingModifierNode is an InsetsPaddingModifierNode that handles actual layout padding and correct resolve of window insets consumed by ancestors.
  • PlatformWindowInsetsPaddingModifierNode is responsible for retrieving platform-specific WindowInsets values. On attachment, it traverses up the modifier chain to find the ancestor PlatformInsetsPaddingModifierNode and establishes a link. It provides the insets back up to this ancestor node.

Fixes CMP-9390 iOS seems to ignore consumeWindowInsets

Testing

Adds skiko tests to WindowInsetsTest

This should be tested by QA

Release Notes

Fixes - Multiple Platforms

  • Fix window insets consumption in system window insets padding modifiers.

@svastven svastven self-assigned this Jan 6, 2026
@svastven svastven changed the title Svastven/consume window insets Fix consuming window insets in system window insets padding Jan 6, 2026
@svastven svastven removed their assignment Jan 6, 2026
insetsCalculation: PlatformWindowInsets.() -> WindowInsets,
): Modifier = this then
PlatformInsetsPaddingModifierElement(inspectorInfo) then
PlatformWindowInsetsPaddingModifierElement(inspectorInfo, insetsCalculation)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding both of them works, but kind of suspicious and creates more elements to allocate/iterate/etc 🤔

Just to be informed: what's about these alternatives?

  1. Delegate PlatformWindowInsetsProviderNode from InsetsPaddingModifierNode (not visa versa).
  2. Using DelegatableNode.visitAncestors(includeDelegates = true)

(1) looks more promising for me. WDYT?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem in general is that both the PlatformWindowInsetsProviderNode and InsetsPaddingModifierNode are traversable (they have different TraverseKey) and need to traverse their respective descendants to update them with ancestor properties.

As for

  1. I have thought about delegating PlatformWindowInsetsProviderNode from InsetsPaddingModifierNode but the problem is that the common InsetsPaddingModifierNode is not a DelegatingNode so we cannot delegate from it to another node. And I am not sure we want to make it a DelegatingNode in common just to use this functionality on the platform level. Also I think that the problem with the delegated node not being discovered would still remain. Or do you see some other option that I don't?
  2. DelegatableNode.visitAncestors(includeDelegates = true) is internal to commonMain so is the idea to use it in InsetsConsumingModifierNode instead of traverseAncestors ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is internal to commonMain

It's internal to the module, not source-set

Copy link

@ASalavei ASalavei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, please fix tests

@svastven svastven force-pushed the svastven/consume-window-insets branch from 3e294b9 to e2c0104 Compare January 15, 2026 14:14
@svastven svastven merged commit 283d269 into jb-main Jan 16, 2026
25 of 26 checks passed
@svastven svastven deleted the svastven/consume-window-insets branch January 16, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants